package com.ogawa.a7517.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import com.ogawa.a7517.R;

public class LeadAdapter extends PagerAdapter {
    private int[] layoutRes = {R.layout.layout_lead_1, R.layout.layout_lead_2, R.layout.layout_lead_3, R.layout.layout_lead_4};

    @Override
    public int getCount() {
        return layoutRes.length;
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        View view = LayoutInflater.from(container.getContext()).inflate(layoutRes[position], null);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View) object);
    }
}
